﻿<%@ Page Title="Văn Bản" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Mauvanban.aspx.cs" Inherits="Mauvanban" %>
<%@ Import Namespace="System.Linq" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <title>Văn Bản</title>
     <div id="slider">
      <div id="info_title">
          <span class="text_title">VĂN BẢN BÁO CÁO THỐNG KÊ KH-CN</span>
      </div>
       
         <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
      <div id="post_wrapper">
        <%
            
            int trang=Convert.ToInt32(Request.QueryString["page"]);
            int sobaihienthi=3;
            int batdautu =trang*3;
            BieumauDataContext db = new BieumauDataContext();
            var dt = from p in db.tblVanBans.Skip(batdautu).Take(sobaihienthi) select new { id=p.IDVanBan,tieude = p.TieuDe, noidung = p.NoiDungTomTat, path = p.URL, ngaydang = p.NgayDang ,tomtat=p.TomTat};
             
        foreach (var vb in dt)
        {
                  string date =vb.ngaydang.Value.ToString("dd-MMM-yyyy");
                  string query =ConfigurationManager.AppSettings["url"]+vb.path;
                  //string query =ConfigurationManager.AppSettings["url"] + vb.path;
                  
        Response.Write("<!--begin--><div class='post_news'>"+
             "<div class='post_title'>"+
                  "<a href='View.aspx?mode=VB&vanban=" + vb.id + "'>" + vb.tieude + "</a>");
      Response.Write("</div>"+
              "<div class='post_content'>");
               Response.Write("<p>"+vb.tomtat+
"<br/><span class='download'><a href='" + vb.path + "'><img src='images/download.png' width='20' height='20' alt='Tải ở đây'>  Tải về</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='Preview.aspx?ID=" + query + "'><img src='images/icons/readme.png' width='20' height='20' alt='Tải ở đây'> Xem online</a></span> </p></div></div><!--end-->");
          
          }
    %>
        
          </div>
        <div id="view_more">
          <div id="title_view_more" >
              <h5>Các văn bản khác</h5>
          </div>
        </div>
          <div id="view_more_content">
              <div id="view_more_items">
                  <% 
                      int total = db.tblVanBans.Count();
                      int set = total / sobaihienthi;

                      int start_more = batdautu + sobaihienthi;
                       if (trang==set)
                       {
                           var more = from p in db.tblVanBans.Skip(0).Take(5) select new {id=p.IDVanBan, tieude = p.TieuDe, noidung = p.NoiDungTomTat, path = p.URL, ngaydang = p.NgayDang };
                           foreach (var i in more)
                           {

                               Response.Write("<div class='items_view'> <a href='View.aspx?mode=VB&vanban=" + i.id + "'>" + i.tieude + "</a></div>");


                           }
                       }
                       else
                       {
                           var more = from p in db.tblVanBans.Skip(start_more).Take(sobaihienthi + 2) select new { id = p.IDVanBan, tieude = p.TieuDe, noidung = p.NoiDungTomTat, path = p.URL, ngaydang = p.NgayDang };
                           foreach (var i in more)
                           {

                               Response.Write("<div class='items_view'><a href='View.aspx?mode=VB&vanban=" + i.id + "'>" + i.tieude + "</a> </div>");


                           }
                       }
                  
                 
                 
                  

                  %>
              </div>
      
              <div id="paging"><ul>
                        <%
                          
                            int n = Convert.ToInt32(Request.QueryString["page"]);
                           
                            if (n<=3)
                            {
                                Response.Write("<li><a href='Mauvanban.aspx?page=0' >«Trang đầu</a></li>");
                                if (set <= 5)
                                {
                                    for (int i = 1; i <set; i++)
                                    {
                                      
                                        int page=Convert.ToInt32(Request.QueryString["page"].ToString());
                                            if (i == page)
                                            {
                                                Response.Write("<li><a class='actived_page' href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                            }
                                            else
                                            {
                                                Response.Write(" <li><a  href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                            }
                                        
                                        

                                    }
                                }
                                else
                                {
                                    

                                    for (int i = 1; i <= 5; i++)
                                    {

                                        Response.Write("<li><a class=");
                                        if(i==Convert.ToInt32(Request.QueryString["page"].ToString()))
                                        {
                                        Response.Write("class='actived_page' href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                        else
                                        {
                                            Response.Write("href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                        

                                    }

                                    
                                }
                                
                                Response.Write("... <li><a href='Mauvanban.aspx?page=" + set + "'>Trang cuối »</a></li>");
                            }
                            else
                            {


                                Response.Write("<li><a href='Mauvanban.aspx?page=0' >«Trang đầu</a></li>");      
                                    for (int i = n - 2; i <= n + 2; i++)
                                    {
                                        if (i == set)
                                            break;
                                        Response.Write("<li><a ");
                                        if (i == Convert.ToInt32(Request.QueryString["page"].ToString()))
                                        {
                                            Response.Write("class='actived_page' href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                        else
                                        {
                                            Response.Write("href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }

                                    }

                                    Response.Write("... <li><a href='Mauvanban.aspx?pagee=" + set + "'>Trang cuối »</a></li>");
                                
                            }
                            
                           
                        %>
                        </ul>
                    </div>
             
          </div>
           </ContentTemplate></asp:UpdatePanel>    
              
     

</div>
      
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>



